#if !defined(AFX_PATMAN_H__8E65E10D_5E11_4161_8CF7_CE73A61687DA__INCLUDED_)
#define AFX_PATMAN_H__8E65E10D_5E11_4161_8CF7_CE73A61687DA__INCLUDED_

#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
// PatMan.h : header file
//

#include "ZhusuPage.h"
#include "HisNowPage.h"
#include "HisPastPage.h"
#include "BodyCheckPage.h"
#include "FirstDiagPage.h"
#include "SubsqtDiagPage.h"
#include "SubsqDiagQueryPage.h"
#include "../Common/LinkEdit.h"
#include "../Common/LinkComboBox.h"
#include "../Common/LinkDate.h"
#include "../Common/GYDataSet.h"
#include "../Common/TabCtrlEx.h"

/////////////////////////////////////////////////////////////////////////////
// CPatMan dialog

#define		TAB_INDEX_ZHUSU				0
#define		TAB_INDEX_NOWHIST			1
#define		TAB_INDEX_PASTHIST			2
#define		TAB_INDEX_BODYCHECK			3
#define		TAB_INDEX_1STDIAG			4
#define		TAB_INDEX_SUBSDIAG			5
#define		TAB_INDEX_SDQUERY			6


class CPatMan : public CDialog
{
// Construction
public:
	CPatMan(CWnd* pParent = NULL);   // standard constructor

	BOOL					SavePatMedInfo();

	BOOL					CheckPatientInfoValid();
	BOOL					IsPatientInfoSaved(){return m_bPatInfoSaved;}

	static BOOL				KeyFieldsCheck(LPVOID pParam);
	static BOOL				LostFocusCheck(LPVOID pParam);

	static BOOL				DateOfBirthCheck(LPVOID pParam);	

	void					EnableTab(int nTabIndex, BOOL bEnable){m_tabTreat.EnableItem(nTabIndex, bEnable);}
	BOOL					IsTabEnabled(int nTabIndex){return m_tabTreat.IsItemEnabled(nTabIndex);}

	void					SelectTab(int nTabIndex){m_tabTreat.SetCurrentTab(nTabIndex);}
	void					SetTabTitle(int nTabIndex, TCHAR* szTitle);
	CPageDialog*			GetTabPage(DWORD dwPageIndex);

	void					QuitPatMan();

// Dialog Data
	//{{AFX_DATA(CPatMan)
	enum { IDD = IDD_DIALOG_PATMAN };
	CLinkComboBox	m_cmbGender;
	CLinkEdit	m_edtClincalDiag;
	CLinkEdit	m_edtHomeAddress;
	CLinkDateEdit	m_edt1stClinicDate;
	CLinkEdit	m_edt1stClinicDoctor;
	CLinkDateEdit	m_edtDateOfBirth;
	CLinkEdit	m_edtPhoneNo;
	CLinkEdit	m_edtWeight;
	CLinkEdit	m_edtStature;
	CLinkEdit	m_edtSerialNo;
	CLinkEdit	m_edtName;
	CLinkEdit	m_edtMedicaRecordNo;
	CBitmapButton	m_btnClose;
	CTabCtrlEx	m_tabTreat;
	//}}AFX_DATA


// Overrides
	// ClassWizard generated virtual function overrides
	//{{AFX_VIRTUAL(CPatMan)
	protected:
	virtual void DoDataExchange(CDataExchange* pDX);    // DDX/DDV support
	//}}AFX_VIRTUAL

	virtual void OnOK();

// Implementation
protected:

	// Generated message map functions
	//{{AFX_MSG(CPatMan)
	virtual BOOL OnInitDialog();
	afx_msg void OnSelchangeTabTreatInfo(NMHDR* pNMHDR, LRESULT* pResult);
	afx_msg void OnBitmapClose();
	afx_msg void OnNewPatientInfo();
	afx_msg void OnEditPatientInfo();
	afx_msg void OnCancelPatientInfo();
	afx_msg void OnSelchangingTabTreatInfo(NMHDR* pNMHDR, LRESULT* pResult);
	//}}AFX_MSG
	DECLARE_MESSAGE_MAP()

private:
	BOOL					ShowTableValues(CLinkEdit* pLinkEdit, CString strFieldName, CString strFieldValue);
	BOOL					ShowTablePatientInfo(CLinkEdit* pLinkEdit, CString strFieldName, CString strFieldValue);

	BOOL					ShowPatientInfoFromTable(CGYDataSet* pDataSet, int nIndex);
	BOOL					ClearPatientData();
	CString					GetUserRealNameFromUserName(CString strUserName);
	
	BOOL					SavePatientTable();
	void					AfterSavePatientTable();

	BOOL					EnableTabAndCtrlsForQuery();		
	BOOL					EnableTabAndCtrlsForNone();		

	BOOL					CheckMRNDuplicate();

private:
	CZhusuPage				m_pageZhusu;
	CHisNowPage				m_pageHisNow;
	CHisPastPage			m_pageHisPast;
	CBodyCheckPage			m_pageBodyCheck;
	CFirstDiagPage			m_pageFirstDiag;
	CSubsqtDiagPage			m_pageSubsqtDiag;
	CSubsqDiagQueryPage		m_pageSubSqtDiagQuery;

	BOOL					m_bPatInfoSaved;

	CString					m_strCurrentName;
	CString					m_strCurrentSN;
};

//{{AFX_INSERT_LOCATION}}
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.

#endif // !defined(AFX_PATMAN_H__8E65E10D_5E11_4161_8CF7_CE73A61687DA__INCLUDED_)
